﻿// JScript 文件
//判断结束日期是否大于开始日期
function compareDate(DateState,DateEnd)
{

var DateOne=document.getElementById(DateState).value;
var DateTwo=document.getElementById(DateEnd).value;
var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));
var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);
var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));

var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));
var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);
var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));

if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) > Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))
{
    alert("开始时间不能晚于结束时间！");
	return false;
}
return true;
}

	//输入验证
	var InvaidChars;
	InvaidChars = "&\'\#%";
	
   	function checkString(userstr,invaidStr,action,len,MaxLen)
	{
		var invaidStrarray = new Array( );
		//判断是否为空
		var i;
		if(len >= 0)
		{
		    if(userstr.length == 0 || userstr.length < len)
		    {		    
		        if(len==0)
		        {
			        alert(action + "不能为空！");
			    }
			    else
			    {
			        alert(action + "不能少于" + len +"位") ;
			    }
			    return false;
		    }
		}
		//判断空格
		var re = / /g;
		var resultStr = userstr.replace(re,"");		
		if(resultStr == "")
		{
			alert("不能完全是空格！") ;
			return false;
		}		
		if(MaxLen!="")
		{
			if(userstr.length > MaxLen)
			{
				
				alert("输入" + action + "不能多于" + (MaxLen) + "个字符！");
				return false;
			}
		}
		
	   if(userstr.indexOf("+")>=0)
		{
			
			alert("输入" + action + "不能包含“+”！");
			return false;
		}
	
		 if(invaidStr=="")
			{
			invaidStr= InvaidChars;
			}
		
			for(i=1;i<=invaidStr.length;i++)
			{
				invaidStrarray[i] = invaidStr.substr(i-1,1);
			}
			for(i=1;i<=invaidStr.length;i++)
			{
				if(userstr.search(invaidStrarray[i])!=-1)
				{
					alert(action + "不能包含“"+ invaidStrarray[i] +"”");
				    	return false;
				}
			}
		
		return true;
	}